//
//  ModuleBPageRouter.swift
//  NCRouterBus
//
//  Created by zhanwenyan on 2018/10/17.
//  Copyright © 2018年 Newcoretech. All rights reserved.
//

import UIKit

class ModuleBPageRouter: NCModuleRouter {
    
    private init() {}
    
    static func shared() -> ModuleBPageRouter {
        return ModuleBPageRouter()
    }
    
    
    func routePage(url: URL?, params: [String : Any]?, onResult: (([String : Any]?) -> Void)?, skipType: PageSkipType) -> UIViewController? {
        if url?.scheme == "ModuleB" && url?.host == "page" {
            let isPresent: Bool
            switch skipType {
            case .push:
                isPresent = false
            case .present:
                isPresent = true
            }
            switch url?.path {
            case "/ModuleBViewController":
                return ModuleBViewController.init(params: params, onResult: onResult, isPresent: isPresent)
            default:
                return nil
            }
        }
        return nil
    }
    
    func hasRoute(url: URL?) -> Bool {
        if url?.scheme == "ModuleB" && url?.host == "page" {
            switch url?.path {
            case "/ModuleBViewController":
                return true
            default:
                return false
            }
        } else {
            return false
        }
    }
}
